﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.DBOper
{
    public class Cls_Product
    {
        public int Id;
        public string ProductNum;
        public string ChannelCount;
        public string MaxLineCount;
        public string MaxBandwidth;
    }

    public class OperateProduct 
    {

        public List<Cls_Product> GetProductList()
        {
            List<Cls_Product> productlist = new List<Cls_Product>();
            string connString = string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0} ;Persist Security Info=False;Jet OLEDB:Database Password={1}", System.Windows.Forms.Application.StartupPath + "\\DB.mdb", Mdl_Class.AccessPassWord);
            using (MyDb_Access mydb = new MyDb_Access(connString))
            {

                try
                {
                    mydb.Open();
                    string sql = "select * from T_Product where Id>0 order by Id";

                    mydb.ExecuteReader(sql);
                    while (mydb.DataReader.Read())
                    {
                        Cls_Product clsproduct = new Cls_Product();

                        clsproduct.Id = Convert.ToInt32(mydb.DataReader["Id"]);

                        clsproduct.ProductNum = mydb.DataReader["ProductNum"].ToString();
                        clsproduct.ChannelCount = mydb.DataReader["ChannelCount"].ToString();
                        clsproduct.MaxLineCount = mydb.DataReader["MaxLineCount"].ToString();
                        clsproduct.MaxBandwidth = mydb.DataReader["MaxBandwidth"].ToString();
                        productlist.Add(clsproduct);
                    }

                    mydb.Close();
                }
                catch (Exception ex)
                {
                    productlist = null;
                    Mdl_Class.WriteLog.dbErrLog("List<Cls_Product> GetProductList()", ex.ToString());
                }
                return productlist;
            }
        }
    }
}
